//
//  NDRefreshControl.h
//  JiMeiUnv
//
//  Created by devp on 14-9-4.
//  Copyright (c) 2014年 nd. All rights reserved.
//

#import <UIKit/UIKit.h>

@protocol NDRefreshControlContainViewDelegate;
/**
 *    刷新执行动作
 *
 */
typedef void(^RefreshControlActionHandler)(id sender);
/**
 *    下拉/上拉进度回调
 *
 */
typedef void(^RefreshControlDraggedProgressHandler)(CGFloat progress);

/**
 *    刷新触发模式 NOTE: TO BE IMPLEMENTED
 */
typedef NS_ENUM(NSInteger, RefreshControlTriggerMode) {
    /**
     *    到达阈值并且释放后触发
     */
    RefreshControlTriggerRelease    =   0,
    /**
     *    到达阈值自动触发
     */
    RefreshControlTriggerAuto       =   1
};

/**
 *    刷新控件位置
 */
typedef NS_ENUM(NSInteger, RefreshControlPosition) {
    RefreshControlPositionTop,      // 顶部下拉刷新
    RefreshControlPositionBottom    // 底部加载更多
};

@interface NDRefreshControl : UIControl
/**
 *    刷新控件引用的滚动视图
 */
@property (nonatomic, weak)     UIScrollView              *scrollView;

/**
 *    是否正在刷新
 */
@property (nonatomic, readonly, getter=isRefreshing) BOOL refreshing;

@property (nonatomic, strong)   UIColor                   *tintColor; // NOTE: TO BE IMPLEMENTED
@property (nonatomic, strong)   NSAttributedString        *attributedTitle UI_APPEARANCE_SELECTOR; // NOTE: TO BE IMPLEMENTED

/**
 *    触发阈值，默认为50
 */
@property (nonatomic, readonly) CGFloat                   threshold;
/**
 *    结束刷新消失动画时长，默认为0.3s
 */
@property (nonatomic, assign)   NSTimeInterval            disappearingTimeInterval;
/**
 *    原始content inset y偏移
 */
@property (nonatomic, assign)   CGFloat                   originalContentInsetY;
/**
 *    刷新触发模式，默认为RefreshControlTriggerRelease
 */
@property (nonatomic, assign)   RefreshControlTriggerMode triggerMode;//  NOTE: TO BE IMPLEMENTED
/**
 *    刷新控件位置，默认为RefreshControlPositionTop
 */
@property (nonatomic, assign)   RefreshControlPosition    position;
/**
 *    内容页view
 */
@property (nonatomic, strong)   UIView<NDRefreshControlContainViewDelegate> *containView;
/**
 *    刷新执行的动作
 */
@property (nonatomic, copy)     RefreshControlActionHandler refreshActionHandler;
/**
 *    下拉/上拉过程进度动作回调
 */
@property (nonatomic, copy)     RefreshControlDraggedProgressHandler draggedProgressHandler;

/**
 *    使用默认值阈值、刷新控件高度创建刷新控件
 */
- (instancetype)init;
/**
 *    使用阈值、刷新控件高度创建刷新控件
 */
- (instancetype)initWithThreshold:(CGFloat)threshold height:(CGFloat)height;
/**
 *    开始刷新
 */
- (void)beginRefreshing;
/**
 *    结束刷新
 */
- (void)endRefreshing;
@end
